<?php
/**
 * the digitalus core class serves as a registry for the cms resources
 *
 * Description for class Core
 *
 * @author:
 */
class Dig_Core_Abstract
{
    const REGISTRY_KEY = 'digitalus_core';
    public $params = array();
    public static function setParam ($key, $value)
    {
        $core = self::getInstance();
        $core->params[$key] = $value;
        $core->save();
    }
    public static function getParam ($key)
    {
        $core = self::getInstance();
        return $core->params[$key];
    }
    static function getInstance ()
    {
        if (! Zend_Registry::isRegistered(self::REGISTRY_KEY)) {
            Zend_Registry::set(self::REGISTRY_KEY, new self());
        }
        return Zend_Registry::get(self::REGISTRY_KEY);
    }
    public function save ()
    {
        Zend_Registry::set(self::REGISTRY_KEY, $this);
    }
    /**
     * handles the setter and getter methods for the params
     *
     * @param string $name
     * @param array $arguments
     */
    public function __call ($name, $arguments)
    {
        $method = Dig_Util_Class::parseMagicMethod($name);
        if ($method) {
            switch ($method->method) {
                case 'get':
                    return $this->params[$method->param];
                    break;
                case 'set':
                    $value = $arguments[0];
                    $this->setParam($method->param, $value);
                    break;
            }
        }
    }
}
?>